<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>登录</title>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
    <meta http-equiv="keywords" name="keywords" content="" />
    <meta http-equiv="description" name="description" content="" />
    <link href="css/ydui.css" rel="stylesheet" />
    <link href="https://cdn.bootcss.com/Swiper/4.2.0/css/swiper.min.css" rel="stylesheet">
    <script src="js/ydui.flexible.js"></script>
	<link rel="stylesheet" type="text/css" href="css/all.css?v=201850002"/>
</head>
	<body>
		<div class="g-flexview" style="background: #00d0ba;"  id="app" v-cloak>
			<div class="g-scrollview">
				<div class="login-content">
					<img src="img/logo-2.png" style="width:30%;margin: 0 auto; position: absolute;top: -1.1rem;left: 34%;"/>
					<div class="select-box">
						<input type="text" v-model="logindata.adminname" placeholder="请输入账号" />				
					</div>	
					<div class="select-box">
						<input type="password"  v-model="logindata.adminpass" placeholder="请输入密码"  />								
					</div>	
					<a v-on:click="login" class="btn-block btn-primary" style="background:#00d0ba;font-size: .3rem;height:.8rem;line-height:.8rem;">登录</a>
				</div>				
			</div>
			<p style="text-align: center;font-size: .24rem;line-height: .8rem;color: #667173;">技术支持：河南精华网络科技有限公司</p>
		</div>
	</body>
    <script src="https://cdn.bootcss.com/jquery/2.2.0/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/vue/2.5.15/vue.min.js"></script>
    <script src="js/ydui.js"></script>
	<script src="js/all.js" type="text/javascript" charset="utf-8"></script>
	<script>
		var model = new Vue({
			el:"#app",
			data:{
				typelist:[],
				jigoutype:"选择",
				depId:"",
				value:"1",
				logindata:{adminname:"",adminpass:""}
			},
			methods:{
		        gettypelist:function(){
					$.getJSON(ComFunJS.APIURL('dept/findDeptByType'),{"type":model.jigoutype},function(r){
						if(r.code==200){
							model.typelist= r.data						
						}
					})  
		        },
        login: function () {
            var data = { "username":model.logindata.adminname, "password": model.logindata.adminpass};                   
            ComFunJS.postJSON(ComFunJS.APIURL('/user/login'),data, function (r) {
                if (!r.error) {
                	if(r.role!='student'){
                		ComFunJS.showMsg('只允许学生登录');   
                		return;
                	}
                	ComFunJS.setCookie("role",r.role)
                	ComFunJS.setCookie("userId",r.userId)	                	
                	ComFunJS.setCookie("orgid",r.orgId)
                	ComFunJS.setCookie("realName",r.realName)
                	localStorage.setItem('user',r.salt);
					window.location.href='index.html'         
                }else{
					ComFunJS.showMsg('账号密码错误');   					
                }
            });
        	},		        
			}
		})
	</script>
</html>
